xquery version "3.0";

let $usersc := 
    for $b in doc("bd-agregador.xml")//usuarios/usuario
    let $ncoments := count(doc("bd-agregador.xml")//app/noticias/noticia/comentarios/comentario[@autor = $b/nickname])
    order by $ncoments descending
    return $b
    
for $b in subsequence($usersc, 0, 10)
let $ncoments := count(doc("bd-agregador.xml")//noticias/noticia/comentarios/comentario[@autor = $b/nickname])
return <resultado-usr nombre="{$b/nombre}" numero_comentarios="{$ncoments}" />
    
    
    
